package de.datenwalze.winterpokal;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;


public class WinterpokalActivity extends TabActivity implements OnClickListener {
static final String TAG = "wpokal";
	

	Button entryButton;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, EntryActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("eintragen").setIndicator("Einheit eintragen",
                          res.getDrawable(R.drawable.ic_tab_edit))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, UserStatsActivity.class);
        spec = tabHost.newTabSpec("user").setIndicator("Benutzer",
                          res.getDrawable(R.drawable.ic_tab_user))
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, TeamActivity.class);
        spec = tabHost.newTabSpec("team").setIndicator("Team",
                          res.getDrawable(R.drawable.ic_tab_team))
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
        
        
        //die views suchen
//        entryButton = (Button) findViewById(R.id.buttonEntry);
//        
//     // add a click listener to the button
//        entryButton.setOnClickListener(new View.OnClickListener() {
//            public void onClick(View v) {
//              //switch to EntryActivity 
//            	
//            }
//        });
        

    }
	@Override
	public void onClick(View v) {
		
		//entryButton = (Button) findViewById(R.id.buttonEntry);
		Log.d(TAG, "EntryClicked");
		startActivity(new Intent(this, EntryActivity.class));

	
	}
	
	//wird aufgerufen, wenn der user das erste mal auf menue drueckt.
	@Override
	public boolean onCreateOptionsMenu(Menu menu){
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.menu, menu);
		return true;
		
	}

//wird aufgerufen, wenn ein optionsmenueelement gedrueckt wird
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()){
		case R.id.itemPrefs:
			startActivity(new Intent(this, PrefsActivity.class));
			break;
		}
		return true;
	}


	
	
	
}
